package com.spc.demo.callback;

import com.spc.demo.constant.Constant;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

/**
 * @author pingchao.su
 * @date 2022/7/13 20:00
 */
public class ComposeSerial {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 返回一个新的CompletableFuture
        // 会等上一个任务结束
        CompletableFuture<Integer> first = Constant.cf.thenCompose(v -> CompletableFuture.supplyAsync(() -> 2));
        System.out.println(first.get());
    }
}
